package com.robotserver.orders.startint;

import com.doudian.open.core.GlobalConfig;
import com.robotserver.orders.mapper.SysSettingMapper;
import groovy.util.logging.Slf4j;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;

import javax.annotation.PostConstruct;

@Component
@Slf4j
public class SystemInit {

    protected final Logger log = LoggerFactory.getLogger(getClass());

    @Autowired
    private SysSettingMapper sysSettingMapper;
    @Value("${taobao.sdk.url}")
    private String taobaoSdkUrl;

    private SystemInit() {
    }

    //静态
    public static SystemInit instance;

    public static SystemInit getInstance() {
        if (instance == null) {
            instance = new SystemInit();
        }
        return instance;
    }

    //注解
    @PostConstruct
    public void init() {
        instance = this;

        String dy_appkey = sysSettingMapper.getByKey("dy_appkey");
        String dy_appsecret = sysSettingMapper.getByKey("dy_appsecret");

        GlobalConfig.initAppKey(dy_appkey);
        GlobalConfig.initAppSecret(dy_appsecret);
        //初始化抖音配置
        log.info("---完成抖音配置初始化---");

    }

    public void startInit() {


    }

}
